//
//  UIAlertController+Blocks.h
//  Hestia
//
//  Created by liufengting on 2018/6/21.
//  Copyright © 2018年 com.hestia. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIAlertController (Blocks)

+ (instancetype _Nonnull)alertWithTitle:(nullable NSString *)title
                                message:(nullable NSString *)message
                            buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                             completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

+ (instancetype _Nonnull)alertWithTitle:(nullable NSString *)title
                                message:(nullable NSString *)message
                            buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                                 cancel:(void(^ _Nonnull )(void))cancel
                             completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

+ (instancetype _Nonnull)alertWithTitle:(nullable NSString *)title
                                message:(nullable NSString *)message
                   textFeildPlaceholder:(nullable NSString *)placeHolder
                            buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                                 cancel:(void(^ _Nonnull )(void))cancel
                             completion:( void(^ _Nonnull )(NSInteger selectedIndex, NSString * _Nullable text))completion;

+ (instancetype _Nonnull)actionSheetWithTitle:(nullable NSString *)title
                                      message:(nullable NSString *)message
                                  buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                                   completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

+ (instancetype _Nonnull)actionSheetWithTitle:(nullable NSString *)title
                                      message:(nullable NSString *)message
                                  buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                                       cancel:(void(^ _Nonnull )(void))cancel
                                   completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

+ (instancetype _Nonnull)alertControllerWithTitle:(nullable NSString *)title
                                          message:(nullable NSString *)message
                                            style:(UIAlertControllerStyle)style
                                       showCancel:(BOOL)showCancel
                                      buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                                           cancel:(void(^ _Nonnull )(void))cancel
                                       completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

@end

@interface UIViewController (AlertBlocks)

- (void )alertWithTitle:(nullable NSString *)title
                message:(nullable NSString *)message
            buttonArray:(NSArray<NSString *> * _Nonnull)buttonArray
             completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

- (void )alertWithTitle:(nullable NSString *)title
                message:(nullable NSString *)message
            buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                 cancel:(void(^ _Nonnull )(void))cancel
             completion:( void(^ _Nonnull )(NSInteger selectedIndex))completion;

- (void )alertWithTitle:(nullable NSString *)title
                message:(nullable NSString *)message
   textFeildPlaceholder:(nullable NSString *)placeHolder
            buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                 cancel:(void(^ _Nonnull )(void))cancel
             completion:(void(^ _Nonnull )(NSInteger selectedIndex, NSString * _Nullable text))completion;

- (void )actionSheetWithTitle:(nullable NSString *)title
                      message:(nullable NSString *)message
                  buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                   sourceView:(UIView *_Nullable)sourceView
                   completion:(void(^ _Nonnull )(NSInteger selectedIndex))completion;

- (void )actionSheetWithTitle:(nullable NSString *)title
                      message:(nullable NSString *)message
                  buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                   sourceView:(UIView *_Nullable)sourceView
                       cancel:(void(^ _Nonnull )(void))cancel
                   completion:(void(^ _Nonnull )(NSInteger selectedIndex))completion;

- (void )alertControllerWithTitle:(nullable NSString *)title
                          message:(nullable NSString *)message
                            style:(UIAlertControllerStyle)style
                       showCancel:(BOOL)showCancel
                      buttonArray:(NSArray<NSString *> * _Nonnull )buttonArray
                       sourceView:(UIView *_Nullable)sourceView
                           cancel:(void(^ _Nonnull )(void))cancel
                       completion:(void(^ _Nonnull )(NSInteger selectedIndex))completion;

@end

